window.onload=function() {
    var uname = document.querySelector('.uname');
    var unameJudge = document.querySelector('.unameJudge');
    var pwdJudge = document.querySelector('.pwdJudge');
    var pwd=document.querySelector('.pwd');
    var reg = /^[a-zA-Z0-9_-]{6,16}$/;
    uname.addEventListener('blur', function () {
        if(this.value!='') {
            if (reg.test(this.value)) {
                unameJudge.innerHTML = '合法';
                unameJudge.classList.add('right');
                unameJudge.classList.remove('wrong');
            } else {
                unameJudge.innerHTML = '请输入6-16位用户名';
                unameJudge.classList.add('wrong');
                unameJudge.classList.remove('right');
                }
        }
        })
    pwd.addEventListener('blur', function () {
        if(this.value!='') {
            if (reg.test(this.value)) {
                pwdJudge.innerHTML = '合法';
                pwdJudge.classList.add('right');
                pwdJudge.classList.remove('wrong');
            } else {
                pwdJudge.innerHTML = '请输入6-16位密码';
                pwdJudge.classList.add('wrong');
                pwdJudge.classList.remove('right');
    
            }
        }
    })
}